#include "stdafx.h"
#include <iostream>
#include "myTemplate_test_fn.h"

#include "myAutoMutexV2.h"

#include "myDoubleLinkList.h"
#include "mySingleLinkList.h"
#include "myClassMemPoolV2.h"

using namespace myFn;
using namespace myFn::v2;
using namespace std;

//namespace test2
//{

class Cint
{
public:
    Cint *next, *prev;
    void *__this_lst;
    int i;
    Cint( int ii = 0 )
    {
        next = prev = 0;
        __this_lst = 0;
        i = ii;
    }
};

class CCi
{
public:
    int i;
    int j;
    int k;
    CCi()
    {
        j = k = i = 0;
    }
    void _InitClass( void *argv )
    {
        i = ( int )argv;
        j++;
    }
    void _UnInitClass()
    {
        k++;
    }
};


typedef mpool::insideItem<CCi, 2> Cii;

//	/*
typedef _myClassMemPoolBase <
CCi, 2
, mpool::initFnEnable
, threadsafe::en
, mpool::allocPtr_inner
, mpool::unallocPtr_simple
>	Aa;
Aa aa2;

myClassMemPool<CCi> aa;

//*/

myClassMemPoolOutEx<CCi, 1> BBa( 5, 4, 10 );
myClsMemPoolOutManagerEx<CCi> Bba( &BBa );


class TestBase1
{
public:
	int a;
};

class TestBase2:public TestBase1
{
public: 
	int b;
};


void test_test_1(TestBase1 &a)
{
	return;
}

void test_myDblst()
{

	TestBase2 aaaa;
	test_test_1(aaaa);

    myDblstEx<Cii> lst;
    Cii i;
    lst.AddItemNextTail( &i );


    CCi *ci[100];
//*
	aa.setPoolSize( 3, 3, 10 );

    for( int i = 0; i < 20; i++ )
    {
        ci[i] = aa.New( ( void * )i );

        if( i % 3 == 2 )
        {
            aa.Delete( ci[i / 3] );
        }
        else if( i % 5 == 2 )
        {
            aa.Delete( ci[i - 1] );
        }
    }

    aa.Delete( ci[2] );

//	/*
    for( int i = 11; i < 30; i++ )
    {
        ci[i] = Bba.New( ( void * )i );
    }

    for( int i = 11; i < 24; i++ )
    {
        Bba.Delete( ci[i] );
    }
//*/
	aa.Recycle();
	aa.clear();
    return;
}







//};// namespace test2
